package com.qf.controller;

import com.qf.pojo.Goods;
import com.qf.pojo.resp.BaseResult;
import com.qf.service.GoodsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/goods")
@Slf4j
public class GoodsController {
    @Resource
    @Autowired
    GoodsService goodsService;
    @RequestMapping ("/findAll")
    public BaseResult findAllGoods(){
        BaseResult baseResult = goodsService.findAllGoods();
        return baseResult;
    }
//    @RequestMapping("/findOne")
//    public Goods findOneById(int gid,Model model){
//        Goods one = goodsService.findOneById(gid);
//        model.addAttribute("one",one);
//        return one;
//    }

    @RequestMapping("/findOne")
    public BaseResult findOneById(int gid){
        BaseResult one = goodsService.findOneById(gid);
        return one;
    }

    @RequestMapping("/findByType")
    public BaseResult findGoodsByType(String t_id){
        BaseResult goods = goodsService.findGoodsByType(t_id);
        return goods;
    }
    @RequestMapping("/findAllType")
    public BaseResult findAllType(){
        BaseResult one = goodsService.findAllType();
        return one;
    }
}
